import java.util.ArrayList;
import java.util.Iterator;

public class IteratorDemo01 {
    public static void main(String[] args) {
        ArrayList arrayList = new ArrayList();
        arrayList.add("喜羊羊");
        arrayList.add("美羊羊");
        arrayList.add("沸羊羊");
        arrayList.add(2,"懒羊羊");
        System.out.println(arrayList);
        Iterator iterator = arrayList.iterator();    //iterator()方法返回一个Iterator对象
        while (iterator.hasNext()) {
            String name = (String) iterator.next();
            System.out.println(name);
        }
    }
}
